﻿namespace WoJ_UT_Mike
{
    using System;
    using System.Collections.Generic;

    using DeltaGroup.WheelOfJeopardy.ChallengeManager;
    using DeltaGroup.WheelOfJeopardy.Model;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    ///This is a test class for ResponseInterpreterTest and is intended
    ///to contain all ResponseInterpreterTest Unit Tests
    ///</summary>
    [TestClass]
    public class ResponseInterpreterTest
    {
        #region Fields

        private TestContext testContextInstance;

        #endregion Fields

        #region Properties

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        ///A test for EvaluateResponse
        ///</summary>
        [TestMethod]
        public void EvaluateResponseEasyLevelTestCorrect()
        {
            DifficultyLevel level = DifficultyLevel.Easy;

            ResponseInterpreter target = new ResponseInterpreter(level);
            Challenge challenge = new Challenge("cat", 100, "Born in back-woods PA, his initials are MAS.", "Who is Michael Shaw?", null, null);

            string responseString = "Michael Shaw";
            bool expected = true;
            bool actual;
            actual = target.EvaluateResponse(challenge, responseString);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for EvaluateResponse
        ///</summary>
        [TestMethod]
        public void EvaluateResponseEasyLevelTestIncorrect()
        {
            DifficultyLevel level = DifficultyLevel.Easy;

            ResponseInterpreter target = new ResponseInterpreter(level);
            Challenge challenge = new Challenge("cat", 200, "Born in back-woods PA, his initials are MAS.", "Who is Michael Shaw?",new List<Synonym>(), null);

            string responseString = "Who is Willy Williams?";
            bool expected = false;
            bool actual = true;
            try
            {
                actual = target.EvaluateResponse(challenge, responseString);
            }catch(Exception unknown){
                Assert.IsFalse(true);
            }
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for EvaluateResponse
        ///</summary>
        [TestMethod]
        public void EvaluateResponseModerateLevelTestCorrect()
        {
            List<Synonym> synonymList = new List<Synonym>();
            synonymList.Add(new ConstructableSynonym("Michael", "Mike"));

            DifficultyLevel level = DifficultyLevel.Medium;

            ResponseInterpreter target = new ResponseInterpreter(level);
            Challenge challenge = new Challenge("cat", 300, "Born in back-woods PA, his initials are MAS.", "Who is Michael Shaw?", synonymList, null);

            string responseString;
            bool actual;

            responseString = "Michael Shaw";
            actual = target.EvaluateResponse(challenge, responseString);
            Assert.IsTrue(actual);

            responseString = "Mike Shaw";
            actual = target.EvaluateResponse(challenge, responseString);
            Assert.IsTrue(actual);
        }

        /// <summary>
        ///A test for EvaluateResponse
        ///</summary>
        [TestMethod]
        public void EvaluateResponseModerateLevelTestIncorrect()
        {
            List<Synonym> synonymList = new List<Synonym>();
            synonymList.Add(new ConstructableSynonym("Michael", "Mike"));

            DifficultyLevel level = DifficultyLevel.Medium;

            ResponseInterpreter target = new ResponseInterpreter(level);
            Challenge challenge = new Challenge("cat", 400, "Born in back-woods PA, his initials are MAS.", "Who is Michael Shaw?", synonymList, null);

            string responseString;
            bool actual;

            responseString = "Andy Shaw";
            actual = target.EvaluateResponse(challenge, responseString);
            Assert.IsFalse(actual);
        }

        /// <summary>
        ///A test for ResponseInterpreter Constructor
        ///</summary>
        [TestMethod]
        public void ResponseInterpreterConstructorTest()
        {
            DifficultyLevel level = DifficultyLevel.Easy;
            ResponseInterpreter target = new ResponseInterpreter(level);
            Assert.IsNotNull(target);
        }

        #endregion Methods
    }
}